package com.breaktian.demoapp.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.breaktian.assemble.serialcache.SerialCache;
import com.breaktian.demoapp.R;
import com.breaktian.demoapp.bean.TestBean;
import com.breaktian.demoapp.provider.BaseProvider;
import com.breaktian.demoapp.ui.base.BaseActivity;

public class TestSerialCacheActivity extends BaseActivity {

    private TextView textCache;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_serial_cache);
        showToolbar("测试缓存");
        int i=0;
        while (i++<40){
            TestBean bean = new TestBean();
            SerialCache.get().saveCacheData("testbean"+i,bean);
        }

        textCache = (TextView)findViewById(R.id.textCache);

        textCache.setText("缓存大小："+SerialCache.get().getCacheSize());

        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SerialCache.get().clearCache();
                textCache.setText("缓存大小："+SerialCache.get().getCacheSize());
            }
        });

    }

    @Override
    protected BaseProvider getProvider() {
        return null;
    }
}
